package framework {
	import flash.display.DisplayObjectContainer;
	import framework.controller.CreateBodyCommand;
	import framework.controller.RetrieveContentCommand;
	import framework.controller.UpdateWorldCommand;
	import framework.model.Box2DWorldModel;
	import framework.service.BlitParser;
	import framework.service.BlitRetrieverService;
	import framework.service.IParser;
	import framework.service.IRetrieverService;
	import framework.service.LoaderSignalsWrapper;
	import framework.service.RetrievalDataStore;
	import framework.signals.CreateBodySignal;
	import framework.signals.RegisterBlitDisplayObjectSignal;
	import framework.signals.RetrieveContentSignal;
	import framework.signals.UpdateWorldSignal;
	import framework.signals.WorldUpdatedSignal;
	import framework.view.BlitCanvasView;
	import framework.view.BlitDisplayObjectMediator;
	import framework.view.BlitDisplayObjectView;
	import framework.view.BlockMediator;
	import framework.view.BlockView;
	import framework.view.Profiler;
	import framework.view.ProfilerMediator;
	import framework.view.RobotlegsPlaygroundMediator;
	import framework.view.WorldCanvasMediator;
	import org.robotlegs.mvcs.SignalContext;
	
	/**
	 * @author Charlie MacIsaac
	 */
	public class RobotlegsPlaygroundContext extends SignalContext {
		// PROPERTIES =============================================================================
		// GETTERS + SETTERS ======================================================================
		// CONSTRUCTOR ============================================================================
		public function RobotlegsPlaygroundContext(contextView : DisplayObjectContainer) {
			super(contextView);
		}
		
		// PUBLIC =================================================================================
		override public function startup() : void {
			super.startup();
			
			// == Profiler ===================================================================
			mediatorMap.mapView(Profiler, ProfilerMediator);
			
			// == Retriever Service ==========================================================
			signalCommandMap.mapSignalClass(RetrieveContentSignal, RetrieveContentCommand);
			injector.mapSingleton(RetrievalDataStore);
			injector.mapClass(IRetrieverService, BlitRetrieverService);
			injector.mapClass(IParser, BlitParser);
			injector.mapClass(LoaderSignalsWrapper, LoaderSignalsWrapper);
			
			// == Blitting ===================================================================
			mediatorMap.mapView(BlitCanvasView, WorldCanvasMediator);
			injector.mapSingleton(RegisterBlitDisplayObjectSignal);
			
			// == Box2d World ================================================================
			// Box2DWorld models all bodies in a physics driven world
			injector.mapSingleton(Box2DWorldModel);
			// World dispatches update signal when it has changed
			injector.mapSingleton(WorldUpdatedSignal);
			// Command updates world when requested
			signalCommandMap.mapSignalClass(UpdateWorldSignal, UpdateWorldCommand);
			
			// == Box2D Bodies ===============================================================
			signalCommandMap.mapSignalClass(CreateBodySignal, CreateBodyCommand);
			mediatorMap.mapView(BlitDisplayObjectView, BlitDisplayObjectMediator, BlitDisplayObjectView, false, false);
			mediatorMap.mapView(BlockView, BlockMediator, BlockView, false, false);
			
			// == LOCAL ======================================================================
			mediatorMap.mapView(RobotlegsPlayground, RobotlegsPlaygroundMediator, RobotlegsPlayground, false, false);
			mediatorMap.createMediator(contextView);
		}
		
		// PRIVATE ================================================================================
		// LISTENERS ==============================================================================
	}
}